home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / DSMODS / HJ.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  8.5 KB  |  336 lines

  1. /*****************************************************************/
  2. /* HISTORY                             */
  3. /*                                 */
  4. /* 11/06/89 - Modified initsys()                 */
  5. /*          added read_GOG() which will read in a GOG.DFT file */
  6. /*          if it exists and use the new LYT,DIC and Dress file*/
  7. /*****************************************************************/
  8.  
  9. #include    <obdefs.h>
  10. #include    <gemdefs.h>
  11. #include    <osbind.h>
  12. #include    "deskset2.h"
  13. #include    "comp.h"
  14.  
  15. #define        FREAD        0
  16.  
  17. char    drsf[]    = "DRESS1.DRS";
  18. char    dicf[]    = "BASIC.DIC";
  19. char    kbdf[]    = "501.LYT";
  20. char    akey1[] = "GoG";
  21. char    akey2[] = "CmP";
  22. char    akey3[6]= { 0xe2, 0xe1, 0xe3, 0xe6, 0xeb, 0 };
  23. char    spbms[] = " ";
  24. char    exdcmd[]= "DSU1.PRG";
  25. char    trncmd[]= "DSU2.PRG";
  26.  
  27. struct txtattr    gltxtattr;
  28. struct textobj    gltext;
  29. int        glgrattr[11];        /* changed 10 to 11 cjg */
  30. char        syspath[100];        /* Boot up system path    */
  31. FDB        char_MFDB;        /* Intellifont MFDB    */
  32.  
  33. long    _stksize =    20240L;
  34.  
  35. extern    char        pathbuf[];    /* current file path    */
  36. extern    unsigned char    ptsfpos[256], mcsdbl[303];
  37. extern    unsigned    H_MARGIN;    /* Horiztal Left margin    */
  38. extern    unsigned    V_MARGIN;    /* Vertical Top    margin    */
  39. extern    char        nuls[];
  40.  
  41. extern int pstorage[];
  42.  
  43. /****************************************************************/
  44. /*            H&J Module Interface              */
  45. /****************************************************************/
  46. init_tattr()
  47. {
  48. /*
  49.     gltxtattr.ptsz  = 24*8;
  50.     gltxtattr.font  = 1;
  51.     gltxtattr.ssiz  = 24*8;
  52.     gltxtattr.lnsp  = (long)pttomu(26);
  53.     gltxtattr.mcomp    = 0;    * Manual char. COMPensation off *
  54.     gltxtattr.acomp    = 0;    * Auto.  char. COMPensation off *
  55.     gltxtattr.kernmd= 0;    * KERNing     MoDe flag off    *
  56.     gltxtattr.hypmd    = 1;    * HYPhenation     MoDe flag on    *
  57.     gltxtattr.nsuchyp= 2;    * No. of SUCcessive    HYPhens    *
  58.     gltxtattr.nbefhyp= 2;    * No. of chars BEFore    HYPhen    *
  59.     gltxtattr.nafthyp= 3;    * No. of chars AFTer    HYPhen    *
  60.     gltxtattr.ltsmd    = 1;    * LetTerSpacing MoDe flag on    *
  61.     gltxtattr.plts    = 3;    * Positive LetTer Space in RU    *
  62.     gltxtattr.nlts    = 1;    * Negative LetTer Space in RU    *
  63.     gltxtattr.minsp    = 12;    * MINimum    SPace     in RU    *
  64.     gltxtattr.prfsp    = 8;    * PReFerred    SPace     in RU    *
  65.     gltxtattr.maxsp    = 30;    * MAXimum    SPace     in RU    *
  66.     gltxtattr.rvomd    = 0;    * Reverse VideO MoDe flag off    *
  67.     gltxtattr.psimd    = 0;    * PSeudo Italic MoDe flag off    *
  68.     gltxtattr.jstmd    = 0;    * JuSTification MoDe flag AJ    *
  69.     gltxtattr.scoff = 0;    * Scan line offset        *
  70. */
  71.     /* See Resource.C for a Description of pstorage[]    */
  72.     gltxtattr.ptsz  = pstorage[9];   
  73.     gltxtattr.font  = pstorage[8];
  74.     gltxtattr.ssiz  = pstorage[10];
  75.     gltxtattr.lnsp  = pstorage[11];
  76.     gltxtattr.mcomp    = pstorage[37];    /* Manual char. COMPensation off*/
  77.     gltxtattr.acomp    = pstorage[38];    /* Auto.  char. COMPensation off*/
  78.     gltxtattr.kernmd= pstorage[12];    /* KERNing     MoDe flag off    */
  79.     gltxtattr.hypmd    = pstorage[39];    /* HYPhenation     MoDe flag on    */
  80.     gltxtattr.nsuchyp= pstorage[40];/* No. of SUCcessive    HYPhens    */
  81.     gltxtattr.nbefhyp= pstorage[41];/* No. of chars BEFore    HYPhen    */
  82.     gltxtattr.nafthyp= pstorage[42];/* No. of chars AFTer    HYPhen    */
  83.     gltxtattr.ltsmd    = pstorage[43];/* LetTerSpacing MoDe flag on    */
  84.     gltxtattr.plts    = pstorage[44];/* Positive LetTer Space in RU    */
  85.     gltxtattr.nlts    = pstorage[45];/* Negative LetTer Space in RU    */
  86.     gltxtattr.minsp    = pstorage[46];/* MINimum    SPace     in RU    */
  87.     gltxtattr.prfsp    = pstorage[47];/* PReFerred    SPace     in RU    */
  88.     gltxtattr.maxsp    = pstorage[48];/* MAXimum    SPace     in RU    */
  89.     gltxtattr.rvomd    = pstorage[13];/* Reverse VideO MoDe flag off    */
  90.     gltxtattr.psimd    = pstorage[49];/* PSeudo Italic MoDe flag off    */
  91.     gltxtattr.jstmd    = pstorage[14];/* JuSTification MoDe flag AJ    */
  92.     gltxtattr.scoff = pstorage[16];/* Scan line offset        */
  93.  
  94. }
  95.  
  96. /*
  97.     Function to initialize with default files
  98. */
  99. initsys()
  100. {
  101.     get_path();            /* For GOG own use...        */
  102.     strcpy(setp.ftdrs,drsf);    /* FonT DResS : dress1.drs    */
  103.     strcpy(setp.edict,dicf);    /* Exc. DICTionary : basic.dic    */
  104.     strcpy(setp.kblyt,kbdf);    /* KeyBoard LaYouT : 501.lyt    */
  105.     setp.omod    = 5;        /* Ouptut device : Atari laser    */
  106.     setp.hylg    = 1;        /* HYphenation LanGuage : ENG    */
  107.  
  108.     IFerr        = 4;        /* no previous cache setup...    */
  109.  
  110.         gltext.slvlist    = (struct slvll *)0L;
  111.         gltext.attr    = &gltxtattr;
  112.  
  113.     char_MFDB.fd_stand    = 0;    /* setup IFont char MFDB    */
  114.     char_MFDB.fd_nplanes    = 1;
  115.  
  116.     H_MARGIN = 0;            /* 0 pica  invisible margin    */
  117.     V_MARGIN = 0;            /* 0 point invisible margin    */
  118.     init_Tpos();            /* setup Text Window vars    */
  119.     read_GOG();            /* Read in GOG defaults, if any */
  120.     sysfiles();            /* load default files...    */
  121.     clear_tags();            /* start with no text tags    */
  122. }
  123.  
  124. /*
  125.     Function to load default files
  126. */
  127. sysfiles()
  128. {
  129.     ld_lyt(setp.kblyt);            /* load Keyboard Layout    */
  130.     ld_lang();                /* load Hyp. language    */
  131.     ld_dict(setp.edict,0);            /* load Dictionary..    */
  132.     ld_dress(setp.ftdrs,0);            /* load Font dress..    */
  133. }
  134.  
  135. /****************************************/
  136. /*    get entry current path        */
  137. /****************************************/
  138. get_path()
  139. {
  140.     syspath[0] = (char)Dgetdrv() + 'A';
  141.     syspath[1] = ':';
  142.     Dgetpath(&syspath[2],0);
  143.     strcat(syspath,"\\");
  144.     strcpy(pathbuf,syspath);
  145. }
  146.  
  147. /*
  148.     Function to report a user message appended with a fixed error
  149.     one selected by argument 'mod'
  150.     Mod :    1 -- Not found on Disk
  151.         2 -- Read Error
  152.         3 -- Write Error
  153. */
  154. setnfd(file,mod)
  155. char *file, mod;
  156. {
  157.     OBJECT    *errobj;
  158.     int    msgno;
  159.     char    *msgp;
  160.  
  161.     if (mod == 1)    msgno = SNF1;
  162.     else
  163.     if (mod == 2)    msgno = SNF2;
  164.     else
  165.     if (mod == 3)    msgno = SNF3;
  166.     else        return;
  167.     rsrc_gaddr(R_STRING,msgno,&msgp);
  168.     rsrc_gaddr(0,SNFMSG,&errobj);
  169.     errobj[SNFILE].ob_spec    = (long)file;
  170.     errobj[SNFMS].ob_spec    = (long)msgp;
  171.     errobj[execform(errobj,0)].ob_state = NORMAL;
  172. }
  173.  
  174. /*
  175.     Function to find & open a file
  176. */
  177. fopfl(file,mod)
  178. char *file;
  179. int mod;
  180. {
  181.     int fid = -1;
  182.     char mpath[100];
  183.  
  184.     if (!findfile(file,mpath) || (fid = open(mpath,mod)) < 0)
  185.         setnfd(file,1);
  186.     return(fid);
  187. }
  188.  
  189. /*
  190.     Load Hyphenation Language
  191. */
  192. ld_lang()
  193. {
  194.     inithyph();                /* init Hyphenation    */
  195.     if (llang(setp.hylg)) {            /* load Hyp. language    */
  196.         do_alert(NORULE);
  197.         return(0);
  198.     }
  199.     else    return(1);
  200. }
  201.  
  202. /*
  203.     Load Dictionary file
  204. */
  205. ld_dict(file,mod)
  206. char *file;
  207. int mod;
  208. {
  209.     int    fid, ok = 0;
  210.     if (mod) {
  211.         if ((fid = open(file,FREAD)) <= 0)
  212.             setnfd(file,1);
  213.     }
  214.     else    fid = fopfl(file,FREAD);
  215.     if (fid > 0) {
  216.         if (!ldict(fid))
  217.             setnfd(file,2);
  218.         else    ok = 1;
  219.     }
  220.     return(ok);
  221. }
  222.  
  223. /*
  224.     Load Keyboard Layout file
  225. */
  226. ld_lyt(file)
  227. char *file;
  228. {
  229.     int    fp, ok = 0;
  230.  
  231.     if ((fp = fopfl(file,FREAD)) < 0) {    /* find it to read..    */
  232.         do_alert(LYTMS1);        /* no use int tables    */
  233.         ok = 1;
  234.     }
  235.     else {
  236.       if (    read(fp,ptsfpos,256) != 256 ||
  237.         read(fp,mcsdbl,303)  != 303  )
  238.         do_alert(LYTMS2);
  239.       else    ok = 2;
  240.       close(fp);
  241.     }
  242.     if (ok) bld_flash();        /* build Fpos to Ascii table    */
  243.     return(ok);
  244. }
  245.  
  246. /*
  247.     This function locates a file, utilizing the current path then
  248.     the boot up path.
  249.     fname        : name of the file to be searched.
  250.     fpname        : buffer to hold full path filename if file found.
  251.     Returns        True/False
  252. */
  253. findfile(fname,fpname)
  254. char *fname, *fpname;
  255. {
  256. extern    char    syspath[];        /* Boot up file path    */
  257. extern    char    pathbuf[];        /* Current file path    */
  258.     char    *sfn, *dfn;
  259.  
  260.     for (    sfn = dfn = fname;*sfn;    /* upper case fname...    */
  261.         *dfn++ = toupper(*sfn++)  );
  262.     strcpy(fpname,pathbuf);
  263.     strcat(fpname,fname);
  264.     if (!access(fpname,0))        /* in current path ?    */
  265.         return(1);
  266.     strcpy(fpname,syspath);
  267.     strcat(fpname,fname);
  268.     if (!access(fpname,0))        /* in boot up path ?    */
  269.         return(1);
  270.     return(0);            /* can't find file...    */
  271. }
  272.  
  273. /*
  274.     Function to run the external Exception Dictionary utility
  275. */
  276. runExDict()
  277. {
  278.     runExtM(0);
  279. }
  280.  
  281. /*
  282.     Function to run the external Text Translation utility
  283. */
  284. runTrans()
  285. {
  286.     runExtM(1);
  287. }
  288.  
  289. /*
  290.     Function to run an external module :
  291.     mode:    0 -- Exception Dictionary
  292.         1 -- Text Translation
  293. */
  294. runExtM(mode)
  295. int    mode;
  296. {
  297.     char    pcmd[100], argm[80], lgn[4];
  298.     char    *Ecmd;
  299.  
  300.     Ecmd = !mode ? exdcmd:trncmd;
  301.     if (!findfile(Ecmd,pcmd)) {
  302.         setnfd(Ecmd,1);
  303.         return;
  304.     }
  305.     strcpy(argm,akey1);
  306.     strcat(argm,spbms);
  307.     strcat(argm,akey2);
  308.     strcat(argm,spbms);
  309.     strcat(argm,akey3);
  310.     if (!mode) {
  311.         strcat(argm,spbms);
  312.         strcat(argm,setp.edict);
  313.         strcat(argm,spbms);
  314.         itoa(setp.hylg,lgn);
  315.         strcat(argm,lgn);
  316.     }
  317.     if (Pexec(0,pcmd,argm,nuls) == -1)
  318.         do_alert(MERM0);
  319. }
  320.  
  321. /*
  322.     Function to write out default setup structure in document
  323. */
  324. write_setp()
  325. {
  326.     return(dwrite(&setp,sizeof(struct pwup)));
  327. }
  328.  
  329. /*
  330.     Function to read in default setup structure from document
  331. */
  332. read_setp()
  333. {
  334.     return(dread(&setp,sizeof(struct pwup)));
  335. }
  336.